
package oneStopShop.Util;


import javax.swing.table.AbstractTableModel;
import java.sql.*;
import java.util.ArrayList;

/**
 *
 * @author Nimila
 */

/*
 * this class is used to make a table model from the database table
 * of board accouts to display them in the UI
 */
public class TableModelTransactionItem extends AbstractTableModel{
   private int colnum = 4;
    private String[] colNames = {"Item Number ","Name             ","Ithem Quantity","Amount  " };

    private ArrayList<String[]> ResultSets;

    public TableModelTransactionItem(ArrayList<String[]> results) {

       ResultSets = results;

//        try {
//            while (rs.next()) {
//
//                String[] row = {rs.getString("billno"),rs.getString("day"),rs.getString("month"),rs.getString("year"), rs.getString("customer name"), rs.getString("tele no"),rs.getString("design length"),
//                    rs.getString("design width"),rs.getString("design"), rs.getString("colours"),rs.getString("positive"),
//                    rs.getString("plate type"),rs.getString("plate"),rs.getString("quantity"),rs.getString("board type"),
//                    rs.getString("gsm"),rs.getString("board"), rs.getString("printing"),rs.getString("laminating"),
//                    rs.getString("cutting"),rs.getString("embosing length"),rs.getString("embosing width"),rs.getString("embosing"),
//                    rs.getString("dicutting"),rs.getString("finalcost"), rs.getString("piece cost")};
//                ResultSets.add(row);
//
//            }
//        } catch (Exception e) {
//            System.out.println("Exception in TableModelPaperAccounts");
//        }

    }

    public Object getValueAt(int rowindex, int columnindex) {

        String[] row = ResultSets.get(rowindex);
        return row[columnindex];

    }

    public int getRowCount() {
        return ResultSets.size();
    }

    public int getColumnCount() {
        return colnum;
    }

    @Override
    public String getColumnName(int param) {

        return colNames[param];

    }

}
